package com.kinptm.masterclock.bean;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import com.kinptm.masterclock.utils.TimeUtil;

import java.io.Serializable;

/**
 * Created by pc on 13-11-8.
 */
@DatabaseTable
public class SpeedTime implements Serializable {
    @DatabaseField(generatedId = true)
    private int id;
    @DatabaseField
    private int day;
    @DatabaseField
    private int hour;
    @DatabaseField
    private int minute;
    @DatabaseField
    private int second;
    @DatabaseField
    private int millis;

    public SpeedTime() {
        this(0);
    }

    public SpeedTime(long speedTime) {
        TimeUtil.transform2Time(speedTime, this);
    }

    public SpeedTime(int day, int hour, int minute, int second, int millis) {
        this.day = day;
        this.hour = hour;
        this.minute = minute;
        this.second = second;
        this.millis = millis;
    }

    public void reset() {
        this.day = 0;
        this.hour = 0;
        this.minute = 0;
        this.second = 0;
        this.millis = 0;
    }

    public long toMillis() {
        return TimeUtil.transform2Millis(this);
    }

    @Override
    public String toString() {
        return "SpeedTime{" +
                "id=" + id +
                ", day=" + day +
                ", hour=" + hour +
                ", minute=" + minute +
                ", second=" + second +
                ", millis=" + millis +
                '}';
    }

    public int getId() {
        return id;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    public int getHour() {
        return hour;
    }

    public void setHour(int hour) {
        this.hour = hour;
    }

    public int getMinute() {
        return minute;
    }

    public void setMinute(int minute) {
        this.minute = minute;
    }

    public int getSecond() {
        return second;
    }

    public void setSecond(int second) {
        this.second = second;
    }

    public int getMillis() {
        return millis;
    }

    public void setMillis(int millis) {
        this.millis = millis;
    }
}
